/**
 * 后台登陆
 */
$(document).ready(function() {
	
	//显示验证码
	adminImgCode('imgcode');
	
	$("#login").click(function() {
		var username = $("#username").val();
		var password = $("#password").val();
		var code = $("#code").val();

		if (username == '') {
			alert('请输入用户名!');
			return false;
		}

		if (password == '') {
			alert('请输入密码!');
			return false;
		}

		if (code == '') {
			alert('请输入验证码!');
			return false;
		}

		$.ajax({
			type : "POST",
			url : "/Ajax/Login/",
			data : "username=" + username + "&password=" + password + "&code=" + code,
			success : function(html) {
				var msg = jQuery.parseJSON(html);
				if (msg.state == 1) {
					window.location.href = '/';
				} else {
					alert(msg.content);
				}
			}
		});
	});
});